package com.ebuy.api.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ebuy.api.domain.TbUserRoleMap;
import com.ebuy.api.mapper.TbUserRoleMapMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: ren.zhong@chebada.com
 * @date: 2023年09月12日11:00:01
 **/
@Service
public class UserRoleService extends ServiceImpl<TbUserRoleMapMapper, TbUserRoleMap> {
    @Autowired
    TbUserRoleMapMapper tbUserRoleMapMapper;


    public List<TbUserRoleMap> getByUserId(Integer userId) {
        LambdaQueryWrapper<TbUserRoleMap> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TbUserRoleMap::getUserId, userId);
        return super.list(wrapper);
    }


    public int deleteByUserId(Integer userId){
        LambdaQueryWrapper<TbUserRoleMap> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TbUserRoleMap::getUserId, userId);
        return tbUserRoleMapMapper.delete(wrapper);
    }
}